Skip to content

Only dismiss the duplicate violation on expenses that have it - #106997

Merged
mollfpr merged 3 commits into
Expensify:mainfrom
mukhrr:fix/106975
Nov 23, 2026
Merged

mollfpr merged 3 commits into
Expensify:mainfrom
mukhrr:fix/106975

Conversation

@mukhrr

@mukhrr mukhrr commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Keep all wrote the duplicate dismissal and the "resolved the duplicate" comment to every expense in the review, but the server keeps them only for expenses with the violation, so on the others the local dismissal later hid the violation once it was raised and the comment disappeared after the request succeeded. Both are now written only to expenses that have the duplicate violation.

Fixed Issues

$ #106975
PROPOSAL:

Tests

Precondition: a workspace with approvals enabled where you are both the submitter and the approver.

  1. Create a manual expense.
  2. Open its report, submit it, approve it, then select Pay > Mark as paid.
  3. Create the same expense again with the same amount, merchant and date, and wait until it shows Potential duplicate.
  4. Open the new expense, click Review duplicates, then Keep all.
  5. Verify neither expense shows Potential duplicate and the new expense's report shows Submit.
  6. Open the paid expense's report and select More > Cancel payment, then More > Unapprove, then More > Retract.
  7. Verify the report shows Review duplicates.
  8. Click Review duplicates and verify both expenses are listed.
  • Verify that no errors appear in the JS console

Offline tests

  1. Follow steps 1 to 3 above.
  2. Open the paid expense once so it is loaded, then go back.
  3. Go offline.
  4. Open the new expense, click Review duplicates, then Keep all.
  5. Verify the Potential duplicate badge and the Review duplicates button are gone on that expense, and its chat shows a greyed "resolved the duplicate" comment.
  6. Open the paid expense and verify its chat shows no "resolved the duplicate" comment.
  7. Go back online.
  8. Verify the paid expense still has no "resolved the duplicate" comment, and on the new expense the comment stays and the badge and button stay gone.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged the Expensify/design team so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
106975-after-android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.app.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
106975-after-web.mp4

Keep all wrote the optimistic duplicatedTransaction dismissal to every transaction in the review. The server stores it only for the ones that carry the violation, so the other transaction kept a local-only dismissal that hid the violation when it was raised on it later, for example after unapproving a paid report.
@mukhrr
mukhrr marked this pull request as ready for review November 17, 2026 02:28
@mukhrr
mukhrr requested review from a team as code owners November 17, 2026 02:28
@expensify-chore-bot
expensify-chore-bot Bot requested review from dylanexpensify and gijoe0295 and removed request for a team November 17, 2026 02:28
@expensify-chore-bot

Copy link
Copy Markdown

@gijoe0295 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T02:46:29.441697Z 893f4a4 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@expensify-chore-bot
expensify-chore-bot Bot removed the request for review from a team November 17, 2026 02:28
@mukhrr

mukhrr commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@mollfpr I am curios if it's expected behavior or not.

  1. Create a manual expense.
  2. Open its report, submit it, approve it, then select Pay > Mark as paid.
  3. Create the same expense again with the same amount, merchant and date, and wait until it shows Potential duplicate.
  4. Open the new expense, click Review duplicates, then Keep all.
  5. Verify neither expense shows Potential duplicate and the new expense's report shows Submit.
  6. Open the paid expense's report and select More > Cancel payment, then More > Unapprove, then More > Retract.
  7. Verify the report shows Review duplicates.
  8. Click Review duplicates and verify both expenses are listed.
image

As you see, after retracting on step 6, we see "Potential duplicate" error message and Review duplicates button on previously paid, but then retracted expense report. But we see neither in the first report.

so is this expected ? cc @gijoe0295

@mukhrr

mukhrr commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Also I found a clear bug with these steps:

  1. Create a manual expense with a new merchant and amount.
  2. Open its report, submit, approve, then Pay > Mark as paid.
  3. Create the same expense again (same amount, merchant, date) and wait for Potential duplicate on it.
  4. Open the paid expense once so it's loaded, then go back.
  5. Go offline
  6. Open the new draft expense, click Review duplicates, then Keep all.
  7. Open the paid expense. Its chat should show a greyed "resolved the duplicate" comment.
  8. Turn Force offline off.
  9. The comment disappears from the paid expense. On the draft expense it stays.
staging.bug.mp4

@mollfpr do you think we should have another follow up for this?

@mollfpr

mollfpr commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@mukhrr yes, the first behavior is expected. The server skips duplicate dismissal for transactions on approved or reimbursed reports, so the paid expense never gets the dismissal. After retract, the server raises the violation again on that expense only. The draft expense keeps its dismissal, so it stays clean.

The second one is a real bug, and it has the same cause. We also add the optimistic "resolved the duplicate" action for the paid expense, but the server never creates it, so it seems disappears when we go online. I think we should fix in here by only adding that action for transactions that have the violation.

…lation

Keep all added the optimistic "resolved the duplicate" report action to every transaction in the review. The server only adds one to the transactions that carry the violation, so on the others the comment showed while offline and disappeared once the request succeeded.
@mukhrr

mukhrr commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@mukhrr yes, the first behavior is expected. The server skips duplicate dismissal for transactions on approved or reimbursed reports, so the paid expense never gets the dismissal. After retract, the server raises the violation again on that expense only. The draft expense keeps its dismissal, so it stays clean.

The second one is a real bug, and it has the same cause. We also add the optimistic "resolved the duplicate" action for the paid expense, but the server never creates it, so it seems disappears when we go online. I think we should fix in here by only adding that action for transactions that have the violation.

thanks Mohammad)
@gijoe0295 we are good to move now

Copy link
Copy Markdown
Contributor

@mollfpr am I right that this PR wants to show the duplicate error message again on an expense that already had it resolved, then went to paid and back? Or am I misinterpreting the steps?

@mollfpr

mollfpr commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@dylanexpensify no, not quite. The paid expense never had the duplicate resolved. In the steps we press "Keep all" on the new expense only. The server skips the dismissal for expenses on approved or paid reports, so the paid expense keeps the violation. After we retract, the server raises it again on that expense. This PR does not change that.

The PR only fixes the local (optimistic) data. Before, "Keep all" also wrote a dismissal and a "resolved the duplicate" comment on the paid expense, even though the server never saves them. Now we write them only on expenses that have the violation. So the comment no longer disappears when the request finishes.

dylanexpensify
dylanexpensify previously approved these changes Nov 19, 2026

@dylanexpensify dylanexpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a product perspective 👍

Copy link
Copy Markdown
Contributor

Got it, so the write only occurs for expenses w/violation now, not on approved/paid ones?

@gijoe0295

gijoe0295 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-11-22.at.00.55.24.mov
Android: mWeb Chrome
Screen.Recording.2026-11-21.at.23.33.48.mov
iOS: HybridApp
Screen.Recording.2026-11-22.at.00.41.50.mov
iOS: mWeb Safari
Screen.Recording.2026-11-22.at.00.41.50.mov
MacOS: Chrome / Safari
Screen.Recording.2026-11-21.at.22.30.24.mov

@gijoe0295

Copy link
Copy Markdown
Contributor

@mukhrr Please resolve the conflict

# Conflicts:
#	tests/unit/TransactionTest.ts
@mukhrr

mukhrr commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@gijoe0295 done

@gijoe0295

Copy link
Copy Markdown
Contributor

LGTM!

@melvin-bot
melvin-bot Bot requested a review from mollfpr November 21, 2026 18:13

@mollfpr mollfpr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks!

@mollfpr
mollfpr merged commit 4a41841 into Expensify:main Nov 23, 2026
37 of 41 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 mollfpr has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.5.53-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR fixes local duplicate-dismissal data to match existing server behavior, without adding a feature, changing the workflow, or making an existing article factually incorrect.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/arosiclair in version: 9.5.53-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants